﻿using System;
using TestByWire.AttributeHandlers;

namespace TestByWire
{
	[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
	public sealed class ResetStubAttribute : Attribute, IContainerInteraction
	{

		/// <summary>
		/// Initializes a new instance of the <see cref="ResetStubAttribute"/> class.
		/// </summary>
		/// <param name="interfaceType">Type of the interface to reset.</param>
		public ResetStubAttribute(Type interfaceType)
			: this(interfaceType, null)
		{
			if (interfaceType == null)
			{
				throw new ArgumentNullException("interfaceType");
			}

			InterfaceType = interfaceType;
		}

		public ResetStubAttribute(Type interfaceType, String fieldName)
		{
			if (interfaceType == null)
			{
				throw new ArgumentNullException("interfaceType");
			}
			
			if (fieldName == String.Empty)
			{
				throw new ArgumentException("fieldName cannot be empty.");
			}

			InterfaceType = interfaceType;
			FieldName = fieldName;
		}

		public string FieldName { get; private set; }
		public Type InterfaceType { get; private set; }

		Type IContainerInteraction.RegistrationType
		{
			get { return InterfaceType; }
		}

		string IContainerInteraction.RegistrationName
		{
			get { return FieldName; }
		}

		public void Execute(IBuildContext buildContext)
		{

		}
	}
}
